//////////////////////////////////////////////////////////////////////
//!\file MetaDataStream.hpp
//!\brief Contains overloaded datastream operators for rapid file-io.
//!\author timmsusa@googlemail.com
//////////////////////////////////////////////////////////////////////

#ifndef METADATASTREAM_HPP
#define METADATASTREAM_HPP
#include <QtCore>
#include <QDataStream>
#include "FileStorageFlac.hpp"

QDataStream& operator<<(QDataStream& out, const QVector< FileStorageFlac >& track);
QDataStream& operator>>(QDataStream& in, QVector< FileStorageFlac >& track);

QDataStream& operator<<(QDataStream& out, const QVector< FileStorageFlac >& list)
{
    foreach(const FileStorageFlac& fs, list)
    {
        out << fs.m_AlbumMd5 << fs.m_AudioMd5 << fs.m_File << fs.m_MetaDataMd5;
    }
    return out;
}

QDataStream& operator>>(QDataStream& in, QVector< FileStorageFlac >& list)
{
    while(!in.atEnd())
    {
        FileStorageFlac fs;
        in >> fs.m_AlbumMd5 >> fs.m_AudioMd5 >> fs.m_File >> fs.m_MetaDataMd5;
        list.push_back(fs);
    }
    return in;
}
#endif // METADATASTREAM_HPP
